package com.zhijiaoyun.controller.api;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhijiaoyun.common.DsConstant;
import com.zhijiaoyun.controller.base.BaseController;
import com.zhijiaoyun.model.Teacher;
import com.zhijiaoyun.model.dto.PageList;

/**
 * @author shisfish
 * @date 2017/10/26
 */
@Controller
@RequestMapping(value = "/api/teacher", produces = "application/json; charset=utf-8")
public class TeacherApi extends BaseController {

    @ResponseBody
    @RequestMapping(value = "/teachers", method = RequestMethod.GET)
    public Map<String, Object> teachers(int pageIndex, int pageSize, String name, HttpServletRequest request) {
        Map<String, Object> map = new HashMap<>();
        PageList<Teacher> buys = teacherService.pageByParams(pageIndex, pageSize, name);
        map.put("list", buys.getList());
        map.put("page", buys.getPageData());
        map.put(DsConstant.CODE, DsConstant.CODE_SUCCESS);
        return map;
    }

}
